/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
/*
 * TrainingBook
 * Copyright (C) Arnaud Duval 2010 <arnaud.duval@gmail.com>
 * 
 * Projects is free software: you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
 * Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * Projects is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License along
 * with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef _TRAINING_BOOK_HPP_
#define _TRAINING_BOOK_HPP_

#include <activity-types.hpp>
#include <string>
#include <list>
#include <Activity.hpp>
#include <user-day.hpp>
#include <Application.hpp>

///@class TrainingBook
///@brief Define the TrainingBook data structure that contains all the data to be saved
class TrainingBook
{
    public:
        ///@brief Default constructor
        TrainingBook();
        ///@brief Copy constructor
        TrainingBook(const TrainingBook&);
        ///@brief Destructor
        ~TrainingBook();
        ///@brief Overload of = operator
        TrainingBook &operator= (const TrainingBook&);
        ///@brief Return Activity types
        ActivityTypes GetActivityTypes();
        ///@brief Read from a xml file
        bool ReadXML(std::string);
        ///@brief Write to a xml file
        bool WriteXML(std::string);
        ///@brief Add a new activity
        void AddActivity(Activity);
        ///@brief Add a new activity header
        void AddActivityHeader(ActivityHeader);
        ///@brief Add a new user day
        void AddUserDay(UserDay);
        ///@brief Delete an activity with given date
        void DeleteActivityByDate(DateTime);
        ///@brief Update an existing activity
        void UpdateActivity(ActivityHeader);
        ///@brief Read TrainingBook from a SportTrack v3 file *.logbook3
        bool ReadSportTrack3File(std::string);
        ///@brief Read TrainingBook from a *.fitlog file
        bool ReadFitlogFile(std::string);
        ///@brief Sort the activities in ascending order depending on their date and time
        void SortActivities();
        ///@brief Return true if an activity with given date already exists
        bool ActivityExistsByDate(DateTime);

        //Getters
        ///@brief Return the date of the last activity
        DateTime GetLastActivityDate() const;
        ///@brief Return the date of the last user day
        DateTime GetLastUserDayDate() const;
        ///@brief Return the last user day
        UserDay GetLastUserDay() const;
        ///@brief Return favourite OSM tiles repository
        std::string GetOsmTilesRepository() const;
        ///@brief Return activity list
        std::list<ActivityHeader> &GetActivities();
        ///@brief Return activity with given date
        ActivityHeader GetActivityByDate(DateTime) const;
        ///@brief Return activity with given id
        ActivityHeader GetActivityById(std::string) const;

        //Setters
        ///@brief Set the activity types
        void SetActivityTypes(ActivityTypes);
        ///@brief Set favourite OSM tiles repository
        void SetOsmTilesRepository(std::string);
		///@brief Set the pointer to the application object
		void SetAppli(Application*);

    protected:

    private:
        ///@brief Name of the file containing the Training Book
        std::string fileName;
        ///@brief Pointer to the structure defining all the parameters of the running application
        Application* appli;
    
        ///@brief Activity types
        ActivityTypes activityTypes;
        ///@brief Favourite OSM tiles repository
        std::string osmTilesRepository;
        ///@brief List of activities headers
        std::list<ActivityHeader> activities;
        ///@brief List of user days
        std::list<UserDay> days;
        
};

#endif // _TRAINING_BOOK_HPP_
